﻿using Furion.DynamicApiController;
using IndoorPosition.Server.Core.Utils;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IndoorPosition.Server.Application
{
    /// <summary>
    /// 楼层相关服务接口
    /// </summary>
    public class FloorAppService : IDynamicApiController
    {
        IFloorService _floorService;

        public FloorAppService(IFloorService floorService)
        {
            _floorService = floorService;
        }

        /// <summary>
        /// 添加楼层
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<int> Add([FromForm]FloorInputDto input)
        {
            return await _floorService.AddAsync(input);
        }

        /// <summary>
        /// 删除楼层
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task Delete(int id)
        {
            await _floorService.DeleteAsync(id);
        }

        /// <summary>
        /// 根据ID获取楼层信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<FloorDto> Get(int id)
        {
            return await _floorService.GetAsync(id);
        }

        /// <summary>
        /// 分页获建筑信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<PagedList<FloorDto>> List(PageInputDto input)
        {
            return await _floorService.ListAsync(input);
        }

        /// <summary>
        /// 下载模型文件
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> DownloadModel(string fileName)
        {
            return await _floorService.DownloadModelAsync(fileName);
        }


        /// <summary>
        /// 下载路径文件
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> DownloadRoute(string fileName)
        {
            return await _floorService.DownloadRouteAsync(fileName);
        }

    }
}
